#!/bin/sh

prefix="/Library/PRIME/lib/ruby"
top=`pwd`
dest="${top}/../../Package/dest"

PATH=/opt/macuim/bin:/bin:/usr/bin

perl -pi -e "s|/usr/local/lib/pkgconfig/|/opt/macuim/lib/pkgconfig/|" extconf.rb
perl -pi -e "s|#!/usr/bin/env ruby|#!/usr/bin/ruby -I${prefix}|" rsary.rb
#perl -pi -e "s|= str2cstr|= rb_str2cstr|" searcher.c

#CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc -arch x86_64" \
ruby extconf.rb

make -w  \
CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -fno-common -arch ppc -arch i386 -arch x86_64 -Os -pipe -fno-common -I/opt/macuim/include -I/opt/macuim/include/glib-2.0 -I/opt/macuim/lib/glib-2.0/include" \
LDFLAGS="-L. -arch ppc -arch i386 -arch x86_64 -framework Carbon -L/opt/macuim/lib -lsary -lgthread-2.0 -lglib-2.0 -lintl -liconv" \
LDSHARED="cc -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup"

#rm -rf ${dest}${prefix}
mkdir -p ${dest}${prefix}

install -Cv -m 644 sary.bundle ${dest}${prefix}
